<template>
  <div class="dialog" v-show="showMask">
    <div class="dialog-container">
      <div class="dialog-title">人员详细信息</div>
      <div class="content">
        <div width="200px">
          <div>编号：{{ personid }}</div>
          <div>姓名：{{ workername }}</div>
          <div>单位：{{ department }}</div>
          <div>岗位：{{ work }}</div>
          <div>需要安全帽：{{ isNeedHelmet }}</div>
          <div>进入时间：{{ enterTime }}</div>
          <div>离开时间：{{ leaveTime }}</div>
        </div>
        <div>
          <img :src="getImgUrl" alt="" id="image" />
        </div>
      </div>
      <div class="btns">
        <div v-if="type != 'confirm'" class="default-btn" @click="closeBtn">
          {{ cancelText }}
        </div>
        <div v-if="type == 'danger'" class="danger-btn" @click="dangerBtn">
          {{ dangerText }}
        </div>
        <div v-if="type == 'confirm'" class="confirm-btn" @click="confirmBtn">
          {{ confirmText }}
        </div>
      </div>
      <div class="close-btn" @click="closeMask">
        <i class="iconfont icon-close"></i>
      </div>
    </div>
  </div>
</template>
<script>
export default {
  props: {
    personid: {
      type: String,
      default: "000000",
    },
    workername: {
      type: String,
      default: "",
    },
    department: {
      type: String,
      default: "",
    },
    work: {
      type: String,
      default: "",
    },
    isNeedHelmet: {
      type: String,
      default: "",
    },
    enterTime: {
      type: String,
      default: "",
    },
    leaveTime: {
      type: String,
      default: "",
    },
    value: {},
    // 类型包括 defalut 默认， danger 危险， confirm 确认，
    type: {
      type: String,
      default: "default",
    },
    content: {
      type: String,
      default: "",
    },
    cancelText: {
      type: String,
      default: "取消",
    },
    dangerText: {
      type: String,
      default: "删除",
    },
    confirmText: {
      type: String,
      default: "确认",
    },
  },
  data() {
    return {
      showMask: false,
    };
  },
  computed:{
    getImgUrl:{
        get(){
            return require("@/assets/images/" + this.personid + ".jpg");
        }
    },
  },
  methods: {
    /******************生成人员照片地址******************/
    
    closeMask() {
      this.showMask = false;
    },
    closeBtn() {
      this.$emit("cancel");
      this.closeMask();
    },
    dangerBtn() {
      this.$emit("danger");
      this.closeMask();
    },
    confirmBtn() {
      this.$emit("confirm");
      this.closeMask();
    },
  },
  mounted() {
    this.showMask = this.value;
  },
  watch: {
    value(newVal) {
      this.showMask = newVal;
    },
    showMask(val) {
      this.$emit("input", val);
    },
  },
};
</script>
<style lang="less" scoped>
#image{
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
}
.dialog {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 9999;
  .dialog-container {
    width: 400px;
    height: 300px;
    background: #ffffff;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    border-radius: 8px;
    position: relative;
    .dialog-title {
      width: 100%;
      height: 60px;
      font-size: 18px;
      color: #696969;
      font-weight: 600;
      padding: 16px 50px 0 20px;
      box-sizing: border-box;
    }
    .content {
      color: #797979;
      width: 400px;
      height: 200px;
      padding: 0 20px;
      box-sizing: border-box;
      display: flex;
    }
    .inp {
      margin: 10px 0 0 20px;
      width: 200px;
      height: 40px;
      padding-left: 4px;
      border-radius: 4px;
      border: none;
      background: #efefef;
      outline: none;
      &:focus {
        border: 1px solid #509ee3;
      }
    }
    .btns {
      width: 100%;
      height: 60px;
      // line-height: 60px;
      position: absolute;
      bottom: 0;
      left: 0;
      text-align: right;
      padding: 0 16px;
      box-sizing: border-box;
      & > div {
        display: inline-block;
        height: 40px;
        line-height: 40px;
        padding: 0 14px;
        color: #ffffff;
        background: #f1f1f1;
        border-radius: 8px;
        margin-right: 12px;
        cursor: pointer;
      }
      .default-btn {
        color: #787878;
        &:hover {
          color: #509ee3;
        }
      }
      .danger-btn {
        background: #ef8c8c;
        &:hover {
          background: rgb(224, 135, 135);
        }
        &:active {
          background: #ef8c8c;
        }
      }
      .confirm-btn {
        color: #ffffff;
        background: #509ee3;
        &:hover {
          background: #6fb0eb;
        }
      }
    }
    .close-btn {
      position: absolute;
      top: 16px;
      right: 16px;
      width: 30px;
      height: 30px;
      line-height: 30px;
      text-align: center;
      font-size: 18px;
      cursor: pointer;
      &:hover {
        font-weight: 600;
      }
    }
  }
}
</style>
